package com.zhangwei.xutils;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.ResType;
import com.lidroid.xutils.view.annotation.ContentView;
import com.lidroid.xutils.view.annotation.ResInject;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;


/**
 * 通过注解+反射的方式初始化App的Ui 事件监听,资源文件  IOC 控制反转  注解
 */


@ContentView(R.layout.activity_main)
public class MainActivity extends ActionBarActivity  {
    @ViewInject(R.id.text)
    private TextView text;
    @ViewInject(R.id.btn)
    private Button btn;
    @ViewInject(R.id.img)
    private ImageView img;

    @ResInject(id = R.string.app_name, type = ResType.String)
    private String appName;
    @ResInject(id = R.mipmap.ic_launcher, type = ResType.Drawable)
    private Drawable drawable;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ViewUtils.inject(this);
        add();

    }





    @OnClick({R.id.text,R.id.btn,R.id.img})
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.text:
                Toast.makeText(MainActivity.this, "text", Toast.LENGTH_SHORT).show();
            break;
            case R.id.btn:
                Toast.makeText(MainActivity.this, "btn", Toast.LENGTH_SHORT).show();
                break;
            case R.id.img:
                Toast.makeText(MainActivity.this, "img", Toast.LENGTH_SHORT).show();
                break;

        }
    }

    private  void  add(){

    }



}
